package com.liruo.learn.spring.mvc.controller.view;

import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author:liruo
 * @Date:2023-02-13-19:11:46
 * @Desc
 */
@Controller
public class ViewResolverController {

    @GetMapping(
            value = "/html"
    )
    public String htmlView(){
        return "meta-res";
    }

    //将accept中application/pdf;q=0.8或者*/*;q=0.8移到最先
    @GetMapping(
            value = "/view/resolver/beanname/pdfview.pdf",
            produces = {"application/pdf", "application/json"}
    )
    public ModelAndView pdfView(){
        return new ModelAndView("pdfView", "user", Map.of("sb1",1,"sb2",2));
    }

    @GetMapping("/view/resolver/map")
    @ResponseBody
    public Map<String,Integer> resBody(){
        return Map.of("sb1",1,"sb2",2);
    }
}
